#include <cstdio>
#include <cstdlib>
using namespace std;

int* InitializeTree(int);

int main()
{
    int length, num;
    int *tree;
    while (true) {
        scanf(" %d %d", &length, &num);
        if (length == 0 && num == 0) 
            break; 
        tree = InitializeTree(length);

        int low, high;
        for (int i = 0; i < num; i++) {
            scanf(" %d %d", &low, &high);
            for (int j = 0; j < length + 1; j++) {
                if (j >= low && j <= high && tree[j] != 0)
                    tree[j] = 0;
            }
        }
        int sum = 0;
        for (int i = 0; i < length + 1; i++)
            sum += tree[i];
        printf("%d\n", sum);
    }

    return 0;
}

int* InitializeTree(int length)
{
    int *temp;
    temp = (int *)malloc(length * sizeof(int) + sizeof(int));
    for (int i = 0; i < length + 1; i++)
        temp[i] = 1;
    return temp;
}